using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Instances;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
    [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin","carShop"} })]
	public class SysCarSuppliesController : BaseController
	{
		private readonly ISysCarSuppliesServer _sysCarSuppliesServer;
		public SysCarSuppliesController(ISysCarSuppliesServer sysCarSuppliesServer)
		{
			_sysCarSuppliesServer = sysCarSuppliesServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add([FromForm]RequestSysCarSuppliesDto dto)
		{
			return Send(await _sysCarSuppliesServer.AddAsync(dto,_account.AId));
		}
        /// <summary>
        /// 不带文件的添加
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Add2(RequestSysCarSuppliesDto dto)
        {
            return Send(await _sysCarSuppliesServer.AddAsync2(dto,_account.AId));
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
		public async Task<IActionResult> Delete(RequestSysCarSuppliesDto dto)
		{
			return Send(await _sysCarSuppliesServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update([FromForm]RequestSysCarSuppliesDto dto)
		{
			return Send(await _sysCarSuppliesServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 详情
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Detail(string id)
		{
			return Send(await _sysCarSuppliesServer.Detail(id));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Pagination(int page,int limit,string key,string shopId,string field,bool? order)
		{
			return Send(await _sysCarSuppliesServer.PaginationAsync(page,limit,key, shopId, field,order));
		}
	}
}
